﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.IO;

namespace HOBA.AjaxDemo
{
    public partial class UpdateNews : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params.Count > 0)
            {
                string path = Request.Params["path"];

                XmlDocument n = new XmlDocument();
                n.Load(path);
                n.GetElementsByTagName("title")[0].InnerText = HttpUtility.UrlDecode(Request.Params["txtNewTitle"]);
                n.GetElementsByTagName("image")[0].InnerText = HttpUtility.UrlDecode(Request.Params["txtNewImage"]);
                n.GetElementsByTagName("description")[0].InnerText = HttpUtility.UrlDecode(Request.Params["txtNewDescription"]);
                n.GetElementsByTagName("content")[0].InnerText = HttpUtility.UrlDecode(Request.Params["editor_content"]);
                n.GetElementsByTagName("author")[0].InnerText = HttpUtility.UrlDecode(Request.Params["txtNewAuthor"]);
                n.GetElementsByTagName("source")[0].InnerText = HttpUtility.UrlDecode(Request.Params["txtNewSource"]);
                n.GetElementsByTagName("lastmoddate")[0].InnerText = HttpUtility.UrlDecode(DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss tt"));
                n.Save(path);

                Response.Write(FileUtility.ReadToEnd(path));
            }
        }
    }
}
